package internationalenergytradingplatform.dao;

import internationalenergytradingplatform.pojo.SupplierAccount;
import internationalenergytradingplatform.pojo.TransporterAccount;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 名称TransporterMapper
 * <p>
 * 描述
 *
 * @version 1.0
 * @author:Zuowenbo
 * @datatime:2024-03-21 17:10
 */
@Mapper
public interface TransporterAccountMapper {
    /**
     * 根据手机号查找运输商全部信息
     */
    @Select("select * from transporter_accountr_tb where tele = #{tele}")
    TransporterAccount getCompanyByTele(String tele);

    /**
     * 插入运输商
     */
    @Insert("insert into transporter_accountr_tb values(#{tele}, #{companyName}, #{password}, " +
            "#{unifiedCreditCode}, #{qualificationCertificateImage}, #{avatarImage}, " +
            "#{transporterAccountStatus}, #{balance})")
    void insertTransporter(TransporterAccount transporterAccount);

    /**
     * 修改运输商信息
     */
    @Update("update transporter_accountr_tb set companyName = #{companyName}, " +
            "password = #{password}, unifiedCreditCode = #{unifiedCreditCode}, " +
            "qualificationCertificateImage = #{qualificationCertificateImage}, " +
            "avatarImage = #{avatarImage} where tele = #{tele}")
    void updateTransporterInfo(TransporterAccount transporterAccount);

    /**
     *
     * @author yingfeng
     * @date 2024/4/3 23:24
     获取全部运输商
     */
    @Select("select * from transporter_accountr_tb")
    List<TransporterAccount> getAllTransporterAccount();

    /**
     * 修改输商状态信息
     */
    @Update("UPDATE transporter_accountr_tb SET transporter_account_status = #{state} WHERE tele = #{tele}")
    int updateTransporterAccountState(@Param("tele") String tele, @Param("state") Integer state);
}
